package tech.aistar.pojo;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;

//这里JsonIgnoreProperties注解，解决索引中字段和实体类非一一对应的而引起的JSON解析问题
@JsonIgnoreProperties(ignoreUnknown = true)
// indexName: 索引名字  createIndex: 用于指定当索引不存在时是否创建索引
@Document(indexName = "songList_index", createIndex = false)
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SongListIndex {
    @Id
    private Integer id;
    @Field(type= FieldType.Text,analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String songTitle;
    @Field(type= FieldType.Text ,analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String singerName;
    @Field(type= FieldType.Text ,analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String lyrics;
    @Field(type= FieldType.Auto)
    private String songListname;
    @Field(type= FieldType.Auto)
    private String img;
    @Field(type= FieldType.Auto)
    private Date duration;
    @Field(type= FieldType.Auto)
    private String album;
    @Field(type= FieldType.Auto)
    private Integer clicks;
}
